package com.woniuxy.service.employee.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.employee.Inspector;
import com.woniuxy.mapper.employee.InspectorMapper;
import com.woniuxy.service.employee.InspectorService;
import com.woniuxy.util.PageData;
import com.woniuxy.util.ResponseData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class InspectorServiceImpl implements InspectorService {
    @Resource
    private InspectorMapper inspectorMapper;
    @Override
    public PageInfo<Inspector> queryInspector(PageData<Inspector> pageData) {
        PageHelper.startPage(pageData.getPageNum(), pageData.getPageSize());
        List<Inspector> inspectors = inspectorMapper.queryInspector(pageData.getParam());
        PageInfo<Inspector> inspectorPageInfo=new PageInfo<>(inspectors);
        return inspectorPageInfo;
    }

    @Override
    public ResponseData<?> addInspector(Inspector inspector) {
        inspectorMapper.addInspector(inspector);
        return new ResponseData<>().OK();
    }

    @Override
    public ResponseData<?> delInspector(Integer id) {
        inspectorMapper.delInspector(id);
        return new ResponseData<>().OK();
    }

    @Override
    public ResponseData<?> editInspector(Inspector inspector) {
        inspectorMapper.updateInspector(inspector);
        return new ResponseData<>().OK();
    }
}
